package tests;

import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Stack;

import il.ac.technion.wiki.api.Content;
import il.ac.technion.wiki.api.WikiPageExceptions;
import il.ac.technion.wiki.api.Word;
import il.ac.technion.wiki.impl.DataBaseStandard;

public class DbStub extends DataBaseStandard {
	
	public void log() {
		String lastMethod = Thread.currentThread().getStackTrace()[2].getMethodName();
		lastMethods.push(lastMethod);
	}
	
	public void printLastMethods() {
		System.out.println(lastMethods);
	}

	public DbStub() {
		super();
		lastMethods.push("DbStub()");
	}
	
	@Override
	public boolean add(Content content) throws WikiPageExceptions {
		log();
		return super.add(content);
	}

	@Override
	public boolean addNeutralWord(Word word) throws WikiPageExceptions {
		log();
		return super.addNeutralWord(word);
	}

	@Override
	public List<Content> find(String word, boolean shouldExist)
			throws WikiPageExceptions {
		log();
		return super.find(word, shouldExist);
	}

	@Override
	public Content getCurrentVersion(String name) throws WikiPageExceptions {
		log();
		return super.getCurrentVersion(name);
	}

	@Override
	public Iterator<Entry<String, Stack<Content>>> getIt() {
		log();
		return super.getIt();
	}

	@Override
	public Content getNext() throws WikiPageExceptions {
		log();
		return super.getNext();
	}

	@Override
	public boolean hasNext() {
		log();
		return super.hasNext();
	}

	@Override
	public boolean isExists(String name) throws WikiPageExceptions {
		log();
		return super.isExists(name);
	}

	@Override
	public boolean remove(String name) throws WikiPageExceptions {
		log();
		return super.remove(name);
	}

	@Override
	public boolean removeNeutralWord(Word existingWord)
			throws WikiPageExceptions {
		log();
		return super.removeNeutralWord(existingWord);
	}

	@Override
	public String removeNeutralWords(String request) throws WikiPageExceptions {
		log();
		return super.removeNeutralWords(request);
	}

	@Override
	public void resetIterator() {
		log();
		super.resetIterator();
	}

	@Override
	public Content returnToPrevVersion(String name) throws WikiPageExceptions {
		log();
		return super.returnToPrevVersion(name);
	}

	@Override
	public boolean update(String name, Content content_)
			throws WikiPageExceptions {
		log();
		return super.update(name, content_);
	}

	public Stack<String> lastMethods = new Stack<String>();

}
